// CSE571 - game.h
// Authors: Jonathan Wald, Daniel Sarfati, Guangle Fan
// Gane class which holds data about a single game on the server side.

#ifndef GAME_H
#define GAME_H

#include <vector>
#include <string>

#include "deck.h"
#include "player.h"

using namespace std;


class Game {

 public:
   enum Type
   {
     STUD,
     DRAW,
     HOLDEM
   };
   string name, port, host;
   vector<Player*> players;
   Type type;
   Game();
   ~Game();
   void init();
   void new_player_added();
   void player_quit(Player* quitPlayer);
   void score_added();
   void restart();
   bool winner_announced() {return winner_announced_;}
   int scores_received() {return scores_received_;}
   void send_card(Player* player);
   void add_card(Card& c);
   Deck deck;
   void printPlayersString();   
   void send_hand(Player* player);
   void initTableCards();
   string label;
   bool suspended;

   // Service methods                                           
   virtual int init (int argc, char *argv[]);
   virtual int fini (void);
   virtual int suspend (void);
   virtual int resume (void);
   virtual int info (char **, size_t = 0);

 private:
   bool running;
   bool winner_announced_;
   int scores_received_;
   Deck tableCards;
      
};

struct player_ptr_less
 : std::binary_function<const Player*, const Player*, bool> {
   bool operator() (const Player* p1, const Player* p2 ) const
   {
      return p1->score > p2->score;
   }
};

#endif
